import { Controller, Body, Put, Req } from '@nestjs/common';
import { UserClient_Service } from '@/modules/businessModule/userClient/userClient.service';
import { IRequest } from '@/common/typeScripts/index';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import {
  UserClient_LinkDistrubute_Dto,
  UserClient_Update_Dto,
} from '../userClient/assets/userClient.dto';
import { util_Index_ReturnContent } from '@/common/util/index';
import { UserClient_WebReturnUser_ReClass } from '../userClient/assets/userClient.class';

@Controller('/web/userClientWeb')
@ApiTags('userClientWeb 前台用户')
export class UserClientWeb_Controller {
  constructor(private readonly userClient_Service: UserClient_Service) {}

  @Put('/update')
  @ApiExtraModels(UserClient_WebReturnUser_ReClass)
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    type: UserClient_WebReturnUser_ReClass,
  })
  async userClientWeb_Update(
    @Req() req: IRequest,
    @Body() body: UserClient_Update_Dto,
  ): Promise<{
    data: UserClient_WebReturnUser_ReClass;
  }> {
    const userClientId = req.user.userId;
    return util_Index_ReturnContent(
      await this.userClient_Service.userClient_Web_Update({ id: userClientId, ...body }),
    );
  }

  @Put('/linkDistrubute')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    summary: '绑定推广关系',
    description: '绑定成功',
    type: '绑定成功',
  })
  async userClientWeb_linkDistrubute(@Req() req: IRequest, @Body() body: UserClient_LinkDistrubute_Dto) {
    return util_Index_ReturnContent(
      await this.userClient_Service.userClientWeb_linkDistrubute(req, body),
    );
  }
}
